{include file="public/adminhead"}

<div class="container-fluid">

  <div class="row">
    <div class="card">
      <div class="card-body">

        <form class="form-horizontal" action="#" method="post" enctype="multipart/form-data" onsubmit="return false;">

          <div class="form-group">
            <label class="col-xs-12" >名称</label>
            <div class="col-xs-12">
              <input class="form-control" type="text"  name="title" placeholder="..">
              <div class="help-block"></div>
            </div>
          </div>
          <div class="form-group">
            <label class="col-xs-12" >图片</label>
            <div class="col-xs-12">
              <button type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传Word
              </button>
            </div>
          </div>
          <div class="form-group">
            <div class="col-xs-12">
              <button class="btn btn-primary" type="button" onclick="sub()">提交</button>
            </div>
          </div>
        </form>

      </div>
    </div>
  </div>

</div>

{include file="public/afooter"}

<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: "{:url('Upload/uploadword')}" //上传接口
            ,accept: "file"
            ,done: function(res){
                //上传完毕回调
                console.log(res.array)
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });

function sub() {
    var formdata = $("form").serialize();
    var url = "{:url('AdminImages/create')}";
    $.post(url,formdata,function (e) {
      if(e.code == 200){
          success("成功");
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 2000);
          window.parent.location.reload();
      }else {
          error("失败");
      }
    })
}
</script>